<template>
   <div class="app-container">
      <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" @submit.native.prevent>
         <el-form-item label="标题" prop="businessName">
            <el-input
               v-model="queryParams.businessName"
               placeholder="标题"
               clearable
               style="width: 200px"
                @keyup.enter="handleQuery"
            />
         </el-form-item>
  
         <el-form-item label="待办类型" prop="largeModuleShow">
            <el-select v-model="queryParams.largeModule" placeholder="待办类型" clearable style="width: 200px">
               <el-option
                  v-for="dict in todoSelectList"
                  :key="dict"
                  :label="dict"
                  :value="dict"
               />
            </el-select>
         </el-form-item>
         <el-form-item>
            <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
         </el-form-item>
      </el-form>

      <el-table v-loading="loading" :data="needdoList" >
         <el-table-column type=index min-width='20' label="序号" >
          <template  #default="scope">
            <span>{{(queryParams.pageNum- 1) * queryParams.pageSize + scope.$index + 1}}</span>
          </template>
 </el-table-column>
         <el-table-column
            label="标题"
            align="center"
            prop="businessName"
            :show-overflow-tooltip="true"
         />
          <el-table-column label="待办类型" align="center" prop="largeModuleShow" width="150">
            <!-- <template #default="scope">
               <dict-tag :options="sys_notice_type" :value="scope.row.noticeType" />
            </template> -->
         </el-table-column>
         <el-table-column label="办理模块" align="center" prop="moduleNameShow" width="150">
            <!-- <template #default="scope">
               <dict-tag :options="sys_notice_type" :value="scope.row.noticeType" />
            </template> -->
         </el-table-column>
       
         <el-table-column label="申请人" align="center" prop="startName" width="150" />
         <el-table-column label="创建时间" align="center" prop="createTime" width="200">
      
         </el-table-column>
         <el-table-column label="操作" align="center" width="150">
            <template #default="scope">
               <el-button link type="primary"  @click="openDetail(scope.row)" >审核</el-button>
            </template>
         </el-table-column>
      </el-table>

      <pagination
         v-show="total > 0"
         :total="total"
         v-model:page="queryParams.pageNum"
         v-model:limit="queryParams.pageSize"
         @pagination="getList"
      />
   </div>

   <ViewPage  @AuthorSuccess="authorSuccess" :isView="false" ref="ViewPageRef" />
</template>

<script setup name="Notice">

const { proxy } = getCurrentInstance();

import * as homeApi  from "@/api/home/index";
import { reactive } from "vue";
import ViewPage from "@/views/details/ViewPage"; //详情页
const ViewPageRef =ref()
const router = useRouter();
 const route = useRoute();
const  needdoList=ref([])
const  todoSelectList=ref([])
const queryParams=reactive({
    pageNum: 1,
    pageSize: 10,
    largeModule:'',
    businessName: '',
    moduleName: undefined,
    orderByColumn: undefined,
    
})
const noticeList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);

const total = ref(0);
const title = ref("");


/** 查询待办列表 */
function getList() {
  loading.value = true;
   homeApi.needTodoList(queryParams).then(response => {
    needdoList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  }).catch(err=>{loading.value = false;});
}

function authorSuccess(params) {
   queryParams.pageNum=1
   getList()
   console.log("调用自己的业务逻辑")
}


function openDetail(row){

   ViewPageRef.value.view(row)
}

/** 搜索按钮操作 */
function handleQuery() {

  queryParams.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

onMounted(() => {

     homeApi.getLargeModules().then(response => {
     todoSelectList.value = response.data;
     //console.log("55",todoSelectList.value)
  });
  if ( route.query.type){
     queryParams.largeModuleShow=route.query.type
  }
  getList();
})



</script>
